// 1. 引入异步对象
import request from '@/utils/request'
// 2. 使用枚举存储接口地址
enum Api {
  getAttrListApi = '/admin/product/attrInfoList',
  deleteAttrApi = '/admin/product/deleteAttr',
  saveAttrInfoApi = '/admin/product/saveAttrInfo',
}

//引入约束
import type { AttrModel, AttrListModel } from './model/attrModel'

// 3. 书写接口函数

/**
 * 定义了一个根据三级导航Id获取属性列表的接口函数
 * @param attrId 
 * @returns 
 */
export const reqGetAttrListDataByCategory3Id = ({ category1Id, category2Id, category3Id }) => {
  return request.get<any, AttrListModel>(`${Api.getAttrListApi}/${category1Id}/${category2Id}/${category3Id}`)
}


//删除属性的接口
export const reqDeleteOneAttr = (attrId: number) => {
  return request.delete(Api.deleteAttrApi + `/${attrId}`)
}

// 3. 添加或者更新属性
export const reqAddOrUpdateAttrInfo = (attrInfo: any) => {
  return request.post(Api.saveAttrInfoApi, attrInfo)
}